package com.copa.gamestore.module.gameNews.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.copa.gamestore.module.gameNews.domain.GameNews;
import com.copa.gamestore.module.gameNews.domain.dto.GameNewsSearchDto;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author copa
 * @createDate 2022-09-25 21:37
 * @function
 */
public interface GameNewsMapper extends BaseMapper<GameNews> {

    @Select("SELECT gn.id, gn.detail_url detailUrl FROM game_news gn " +
            "LEFT JOIN game_news_detail gnd on gn.id = gnd.game_news_id " +
            "WHERE year(sale_time) = #{year} AND gnd.id IS NULL")
    List<GameNews> selectBySaleTimeYear(@Param("year") Integer year);

    List<GameNews> selectByYearMonth(@Param("gameNewsSearchDto") GameNewsSearchDto gameNewsSearchDto);

}
